package com.pai4j.pgc.dao.community;
import com.pai4j.pgc.entity.community.CCPathEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *
 *
 * @author: CYM-pai
 * @date: 2025/10/27 14:36
 **/
@Repository
public interface ICCPathDAO extends JpaSpecificationExecutor<CCPathEntity>, JpaRepository<CCPathEntity, Long> {


    Page<CCPathEntity> findAllByNameLike(String name, Pageable pageable);

    List<CCPathEntity> findAllByStatus(String status);
    List<CCPathEntity> findAllByStatusOrderByIdDesc(String status);

    @Query(value = "select * from pai4j_path p where p.recommend = true and p.status = 'PUBLISHED' order by recommend_date desc limit :size", nativeQuery = true)
    List<CCPathEntity> findAllByRecommendAndDeletedOrderByRecommendDateDesc(int size);

    @Query(value = "select * from pai4j_path p where p.sub_money is not null and p.sub_money > 0 and p.status = 'PUBLISHED' order by sub_money desc", nativeQuery = true)
    List<CCPathEntity> findAllBySubscribePaths();
}
